import httplib2
from pkg.voice import out
import gl


def http_download(url,file_name):
    try:
        out.output_thread('开始下载！')
        http=httplib2.Http(gl.g_http_catch_dir)
        status,content=http.request(url)
        if status.status!=200:
            out.output('下载失败')
            return False
        f=open(gl.g_download_dir+'/'+file_name,'wb')
        f.write(content)
        f.close()
        out.output('下载成功')
    except Exception as Err:
        print(Err)
        out.output("网络错误")
        return False
